package com.itkaien.javaeebased.multipleSystem;

import com.itkaien.javaeebased.networkprogerma.MultipleForkSendFile;
import java.io.IOException;
import java.net.Socket;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.concurrent.*;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class App {

    public static void main(String[] args) throws ExecutionException, InterruptedException, IOException {

//        wokr01 wokr01 = new wokr01();
//        Thread thread = new Thread(wokr01);
//        thread.setName("work01");
//        thread.start();
//
//
//        // 这里可以继续添加其他系统的线程
//        Thread thread1 = new Thread(wokr01);
//        thread1.setName("work02");
//        thread1.start();


//        Work02 work02 = new Work02();
//        work02.start();
//
//        Work02 work021 = new Work02();
//        work021.start();

//        Lock lock=new ReentrantLock();
//        Work3 work3 = new Work3(100,lock);
//        Thread thread = new Thread(work3);
//        thread.setName("work03");
//        thread.start();
//        Thread thread1 = new Thread(work3);
//        thread1.setName("work04");
//        thread1.start();

//        Lock lock=new ReentrantLock();
//        Work04 work04 = new Work04(100,lock);
//        Thread thread = new Thread(work04);
//        thread.setName("work041");
//        thread.start();
//        Thread thread1 = new Thread(work04);
//        thread1.setName("work042");
//        thread1.start();

//        ArrayList<Integer> lockList=new ArrayList();
//
//        Collections.addAll(lockList,10,5,20,50,100,200,500,800,2,80,300,700);

//        work7 work7 = new work7(lockList);
//        work7 work71 = new work7(lockList);
//        work7.setName("work7");
//        work71.setName("work71");
//        work7.start();
//        work71.start();

//        work7CallAble work7CallAble = new work7CallAble(lockList);
//
//
//        FutureTask<Integer> featureTask = new FutureTask(work7CallAble);
//        FutureTask<Integer> featureTask1 = new FutureTask(work7CallAble);
//
//        Thread thread = new Thread(featureTask);
//        Thread thread1 = new Thread(featureTask1);
//
//        thread.setName("work7");
//
//        thread1.setName("work71");
//
//        thread.start();
//
//        thread1.start();
//
//        Integer o = featureTask.get();
//
//        Integer o1 = featureTask1.get();
//
//        System.out.println("max1"+o+"  max2"+o1);

//        Arrays.asList("work8","work81");
//        ExecutorService executorService = Executors.newCachedThreadPool();

//        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(5, 10, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<>(10));
//
//        Work08ThreadExcutor work8 = new Work08ThreadExcutor();
//
//        FutureTask<Integer> futureTask = new FutureTask<>(work8);
//
//        threadPoolExecutor.submit(futureTask);
//        Integer re1= futureTask.get();
//        System.out.println(re1);
//
//
//        Thread thread = new Thread(futureTask);
//        thread.setName("work08");
//        thread.start();
//        Integer re = futureTask.get();
//        System.out.println(re);
//
//        threadPoolExecutor.shutdown();

        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(5, 10, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<>(10));
        Socket localhostSocker = new Socket("localhost", 8888);
        threadPoolExecutor.submit( new MultipleForkSendFile(localhostSocker));



    }
}
